<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #wrap{
    position: relative;
    width:600px;
    height:395px;
    margin:auto;
    border:2px solid #000;
    cursor: pointer;
}
#wrap img{
    position: absolute;
    display: none;
}
#wrap .on{
    display:block;
}
    </style>
</head>
<body>
    <div id="wrap">
        <img id="img1" class="on" src="/01.png" alt="">
        <img id="img2" src="/02.png" alt="">
     </div>
     <script>
        var img1 = document.getElementById("img1");
        var img2 = document.getElementById("img2");

        img1.style.margin="10px";

        img1.onmouseover = function(){
            img1.className ="";
            img2.className ="on";
        }

        img2.onmouseover = function(){
            img2.className ="";
            img1.className ="on";
        }
     </script>
</body>
</html>